package main

import "github.com/gin-gonic/gin"

import . "gin_restful/api"

func initRouter() *gin.Engine {
	router := gin.Default()
	router.GET("/", IndexUsers) //  http://127.0.0.1:8088

	// 路由群组
	users := router.Group("api/v1/users")
	{
		users.GET("", GetAll)             // http://127.0.0.1:8088/api/v1/users
		users.POST("/add", AddUsers)      //http://192.168.2.132:8806/api/v1/users/add
		users.GET("/get/:id", GetOne)     //http://192.168.2.132:8806/api/v1/users/get/5
		users.POST("/update", UpdateUser) //http://192.168.2.132:8806/api/v1/users/update
		users.POST("/del", DelUser)       //http://192.168.2.132:8806/api/v1/users/del

	}

	departments := router.Group("api/v1/department")
	{
		departments.GET("", GetAll)
		departments.POST("/add", AddUsers)
		departments.GET("/get/:id", GetOne)
		departments.POST("/update", UpdateUser)
		departments.POST("/del", DelUser)
	}

	return router
}
